package com.shoulder.boot.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shoulder.boot.system.dto.LogQueryDTO;
import com.shoulder.boot.system.service.LogService;
import com.shoulder.boot.system.vo.LogVo;
import com.shoulder.core.api.ApiResult;
import com.shoulder.core.page.PageSchema;
import com.shoulder.log.annotation.LogAnnotation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日志信息管理
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/api/v1/system/log")
public class LogController {

    private final LogService logService;

    /**
     * 查询日志信息分页数据
     *
     * @param queryDTO 日志查询请求体
     * @return 日志分页数据
     * @author 596776880@qq.om
     */
    @LogAnnotation(type = "日志信息分页查询", record = false)
    @PostMapping("/page")
    public ApiResult<PageSchema<LogVo>> pageQuery(@RequestBody LogQueryDTO queryDTO) {
        Page<LogVo> page = this.logService.pageQuery(queryDTO);
        return ApiResult.ok(new PageSchema<>(page.getTotal(), page.getRecords()));
    }
}